<?php
require_once ('initialize.php');
include_once(Utils::getPath(array('shared', 'template.php')));

$template = new Template('main');
$template->initialize();
?>
<div id="documentation">
    <h2>
        DevNetwork</h2>
    <h3>
        Team:</h3>
    <p>
        The team members of this project are:</p>
    <ul>
        <li>
            V&iacute;ctor Ferrer Garc&iacute;a</li>
        <li>
            Manuel Caballero S&aacute;nchez</li>
        <li>
            Daniel C&aacute;ceres Ma&ntilde;a</li>
    </ul>
    <h3>
        Development tools</h3>
    <p>
        The following languages have been used for development, as these were specified requirements for it:</p>
    <ul>
        <li>
            PHP</li>
        <li>
            XHTML 1.0</li>
        <li>
            CSS</li>
        <li>
            JavaScript</li>
        <li>
            SQL</li>
    </ul>
    <p>
        NetBeans 7.0.1 has been chosen as the integrated development environment. We used XAMPP 1.7.4 for servers (Apache and MySQL), and MySQL Workbench 5.2 to perform administrative tasks. Finally we have chosen Google Code as Subversion server.</p>
    <h3>
        Database</h3>
    <p>
        MySQL was used for the database. It provides UTF-8 character encoding, which we used for all tables in the project.</p>
    <p>
        The following diagram provides an overview of the designed database.</p>
    <div class="documentation-img">
        <img alt="Database diagram" src="<?php echo Utils::getUrl('/content/doc/db-diagram.png') ?>" /></div>
    <p>
        As we see in the diagram, the database is in 3NF, as we will prove. The definition of 3NF requires compliance with the 2NF and 1NF too.</p>
    <h3>
        1NF:</h3>
    <ul>
        <li>
            <strong>There&#39;s no ordering to the rows or columns</strong>. Our database does not need the rows or columns to be in any specified order to store the information correctly.</li>
        <li>
            <strong>There are no duplicate rows</strong>. There are no rows in any table representing the same information.</li>
        <li>
            <strong>Every cell value is atomic</strong>. This definition is easy to verify since no column will contain lists or other non-atomic values.</li>
    </ul>
    <h3>
        2NF:</h3>
    <ul>
        <li>
            <strong>It must be 1NF.</strong> It&rsquo;s just been shown it is.</li>
        <li>
            <strong>All the columns that are part of a key candidate must provide complete information about the key. </strong>To meet this definition, the column &#39;Id&#39; has been used as primary key for most tables. The only exception is the table &#39;friends&#39;, which provides information on the relationship of the primary key {&#39;IdUser1&#39;, &#39;IdUser2&#39;}.</li>
    </ul>
    <h3>
        3NF:</h3>
    <ul>
        <li>
            <strong>It must be 2NF.</strong></li>
        <li>
            <strong>There are no transitive dependencies. </strong>To fulfill these requirements it is necessary not to be able to get the same data in two different ways. For example, if we eliminated the table &#39;challenge_categories&#39; and their attributes are found in table &#39;challenges&#39;, the column &#39;Description&#39; would have a transitive dependency with respect to &#39;Id&#39; of &#39;challenge&#39; through the column &#39;Name&#39;.</li>
    </ul>
    <h3>
        Server Code</h3>
    <p>
        We use PHP for the server code. We have designed a structure to access the database, to simplify the query execution and improve safety.</p>
    <p>
        On one side, the pattern &#39;Singleton&#39; has been used to concentrate all calls to the database on a single object, reducing the creation of connections. We created a wrapper class which uses &#39;PDO&#39; to run the queries on the database to facilitate query construction and control of errors with the database.</p>
    <div class="documentation-img">
        <img alt="Database Classes UML" src="<?php echo Utils::getUrl('/content/doc/database.png') ?>" /></div>
    <p>
        On the other hand we have the set of classes that model the database and their corresponding repositories for common tasks.</p>
    <div class="documentation-img">
        <img alt="Repositories Classes UML" src="<?php echo Utils::getUrl('/content/doc/repositories.png') ?>" /></div>
    <h3>
        Views, Client Code and Styles</h3>
    <p>
        For the generation of HTML pages we have created a template system. For this we have implemented a class called &#39;Template&#39;.</p>
    <div class="documentation-img">
        <img alt="Template Class UML" src="<?php echo Utils::getUrl('/content/doc/template.png') ?>" /></div>
    <p>
        The constructor is given the name of the template and this generates the layout file path. Then, the &quot;initialize&quot; method contains custom code for each template, and initializes the PHP output buffer with the call to &#39;ob_start ()&#39;. Finally, the method &#39;createPage&#39; receives the title of the view, and then the contents of the output buffer are stored in a variable to be printed later. Finally the layout is executed and the page is returned to the client.</p>
    <p>
        Another important aspect is the file &#39;initialize.php&#39;, which is included in all PHP files that generate views. It contains among other things, the application path on the server, and its relative URL.</p>
    <p>
        We have also implemented two classes with useful features.</p>
    <div class="documentation-img">
        <img alt="Misc Classes UML" src="<?php echo Utils::getUrl('/content/doc/misc.png') ?>" /></div>
    <h3>
        Client Code</h3>
    <p>
        As client code Javascript has been used, together with libraries like jQuery and some plugins, and making use of AJAX. We have implemented the validation, paging of the comments, messages, among other features. Of course, as specified in the requirements of the project there are some parts of the implementation that do not use any external library.</p>
    <p>
        Finally remark that the CSS version used is 3, though not in its final version has already released the W3C validators.</p>
    <div id="documentation-links">
        <p>Some links: </p>
        <ul>
            <li><a href="<?php echo Utils::getUrl('/content/doc/DevNetwork.pdf') ?>">Documentation PDF</a></li>
        </ul>
    </div>
</div>
<?php
$template->createPage('About Page');
?>